package com.ali.framework.controller;

import com.ali.framework.feign.PayFeignSen;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Smile
 * @Date: 2023/12/18/14:47
 * @Description:
 */
@RestController
@Slf4j
public class FrameOrderController {

    @Autowired
    private PayFeignSen payFeign;

    /*@RequestMapping("/order/test")
    //@SentinelResource(value = "fallback",fallback = "handelback") //运行时异常
    //@SentinelResource(value = "fallback",blockHandler = "blockhandelback") //负责sentinel控制台的配置是否违规
    @SentinelResource(value = "fallback",fallback = "handelback"
            ,blockHandler = "blockhandelback"
            ,exceptionsToIgnore = {ArithmeticException.class}) //两个都配置blockHandler优先,exceptionsToIgnore忽略这个异常
    public String test(){
        int i = 1/0;
        return payFeign.payTest();
    }*/

    /*public String handelback(){
        return "请求失败";
    }*/

    /*public String blockhandelback(){
        return "请求失败";
    }*/

    @GetMapping("/order/testA")
    public String testA(){
        //int i = 1/0;
        return payFeign.payTest();
    }

}


